home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tiger Disk 11
/
Tiger_Disk_011_19xx_Tiger-Crew-Disk_de_Side_B.d64
/
1541 alignment
(
.txt
)
next >
Wrap
Commodore BASIC
|
2023-02-26
|
3KB
|
118 lines
10 rem check/re-align a 1541
20 :
30 rem see prototype and instructions in
40 rem g. neufeld's "1541 user's guide" section 12.5
50 rem rewrite by dave walton
60 print"[147] 1541 alignment"
70 print" insert standard disk"
80 dim e$(16)
90 d=8:rem drive #
100 sid=54272:z$=chr$(0):dc$=z$+chr$(28)+chr$(1)
110 fori=sidtosid+23:pokei,0:next
120 pokei,15:pokesid+5,9
130 e$(0)=" "
140 e$(1)="ok "
150 e$(2)="close to halfway "
160 e$(3)="halfway (no data found)"
170 e$(9)="close to halfway "
180 c$="":fori=1to11:read a:c$=c$+chr$(a):next
190 print" press any key to start"
200 geta$:ifa$="" then200
210 open 5,d,15
220 rem send machine code to drive
230 rem (jump job runs in buf #0)
240 print#5,"m-w"z$chr$(3)chr$(11)c$
280 :
290 rem send "init disk" cmd to drive
300 print#5,"i":print"[147]":t=18
380 :
390 rem new track - show "??"
400 e=0
480 :
490 rem read the disk controller port
500 print#5,"m-r"dc$
510 get#5,a$:a=asc(a$+z$)
520 cv=3anda
530 a=(159anda)or(100+32*((t>17)+(t>24)+(t>30)))
540 print#5,"m-w"dc$chr$(a)
580 :
590 rem display values
600 t$=str$(tr):s$=str$(se):if e<>1 then t$="??":h1$="?":h2$="?":s$="??"
610 print" align the 1541 drive"
620 print"track position:"t"[157] "
630 print"track # read: "right$(t$,2)
640 print"sector # read: "right$(s$,2)
650 print"disk id read: "h1$;h2$
660 print"read results:"e$(e)
680 :
700 print"commands:"
710 print" f1 = move head out (lower track #)
720 [153]" f2 = move head to track 1
730 print" f3 = move head in (higher track #)
740 [153]" f4 = move head to track 35
750 print" f5 = initialize (to track 18)"
760 print" f7 = end program"
780 :
790 rem check keyboard
800 geta$:k=asc(a$+z$)-132
810 ifk>0then onkgoto1300,1320,300,1800,1340,1360
860 :
870 rem attempt to read any header
880 :
890 rem put jmp job in the job queue
900 print#5,"m-w"z$z$chr$(1)chr$(208)
980 :
990 rem check results
1000 print#5,"m-r"z$z$
1010 get#5,a$:e=asc(a$+z$)
1020 rem "e" is fdc error code returned
1030 ife=3 then fh=20:goto 1200
1040 ife=2 or e=9 then fh=30:goto1200
1050 ife<>1 then400
1080 :
1090 rem read ok; get id, track, sector
1100 print#5,"m-r"chr$(22)z$chr$(4)
1110 get#5,h1$,h2$,h3$,h4$
1120 tr=asc(h3$+z$)
1130 se=asc(h4$+z$)
1140 goto500
1180 :
1190 rem boing sound
1200 pokesid+4,0
1210 pokesid+1,fh
1220 pokesid+4,17
1230 goto500
1280 :
1290 rem move head in or out
1300 ift>1 then1500
1310 goto900
1320 ift<40 then c=1:goto1510
1330 goto900
1340 ift>1 then c=-1:l=2*(t-1):goto1400
1350 goto900
1360 ift<35 then c=1:l=2*(35-t):goto1400
1370 ift=35 then900
1380 c=-1:l=2*(t-35)
1400 fori=1tol:gosub1600:next:goto400
1500 c=-1
1510 gosub1600:goto400
1580 :
1590 rem move head one half-track
1600 t=t+c*.5
1610 cv=(cv+c)and3:a=(252anda)+cv
1620 print#5,"m-w"dc$chr$(a):return
1780 :
1790 rem end program (turn drive off)
1800 print#5,"m-w"dc$chr$(240)
1810 fori=sid tosid+23:pokei,0:next
1820 forj=1to100:nextj:pokei,0
1830 close5:end
2000 :
2010 rem machine code routine to read a header
2020 rem resides at $0300 (buffer #0)
2030 data 169,48: :rem lda #$30
2040 data 133,69: :rem sta $45
2050 data 169,00: :rem lda #$00
2060 data 133,63: :rem sta $3f
2070 data 76,177,243 :rem jmp $f3b1